import json,sys
broken_list=[]
undefine_set=set()
#map_dict=json.load(open(sys.argv[1],"r"))
map_dict=json.load(open("/home/dawn/pkuxkx/data/map-pkuxkx.json"))
id_list=[]
def getfullname(a):
    for i in map_dict.keys():
        if a == map_dict[i]["id"]:
            return i
    return 0
for cur_lid in map_dict.keys():
    id_list += [map_dict[cur_lid]["id"]]
# 短id列表准备完成

for cur_lid in map_dict.keys():
    for cur_conn in map_dict[cur_lid]["conn"]:
        if cur_conn not in id_list:
            undefine_set |= {cur_conn} # 利用集合的元素具有不可重复性，|表示并集，对于这里来说就是往集合里塞东西
        elif len(map_dict[cur_lid]["conn"][cur_conn]) == 0:
            tmp = "{frm}到{to}".format(frm=map_dict[cur_lid]["name"],to=map_dict[getfullname(cur_conn)]["name"])
            broken_list += [tmp]

print("发现{count}个未定义地点，列表如下".format(count=len(undefine_set)))
for i in undefine_set:
    print(i)
print("发现{count}个未设置路径的区段，列表如下".format(count=len(broken_list)))
for i in broken_list:
    print(i)